<?php

namespace app\common\model\Airline;

use think\Model;
use think\Request;

class Uav extends Model
{
    protected $name = 'uav';

    protected $autoWriteTimestamp = true;
    protected $updateTime = false;
    protected $createTime = 'createtime';

    // 无人机类型
    public function uavtype()
    {
        return $this->belongsTo('app\common\model\Airline\Uavtype', 'uavtype_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }

    protected $append = [
        'status_text',  //无人机状态
    ];
    
    public function getStatusTextAttr($value, $data){
        $list = ['0' => '待命', '1' => '运行中', '2' => '维修中'];
        $status = !empty($data['status']) ? $list[$data['status']] : '';

        return $status;
    }
}
